<%@page import="java.util.List"%>
<%@page import="multiface.valentinorusso.jpa.Categoria"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="multiface.valentinorusso.jpa.util.PersistenceManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%
    String id = request.getParameter("id");
    String style_sotto_menu_cat = "display: none; opacity: 0.25";
    String aperto="0";
    if (id != null) {
        aperto="1";
        style_sotto_menu_cat ="";
    }
%>
<style>
    .grassetto{
        font-weight: 600;
        color:#B8130F;
        width: 8px;
    }
    .grassetto a{
        color:#B8130F;
    }
    a{
        text-decoration: none;
        color: black;
    }

    #sotto-menu-cat{

    }
    #sotto-menu-cat div a{
        margin-left: 3px;
    }

    #sotto-menu-cat div a{
        font-size: 10px;
        color: #222;
    }

</style>
<script>
    function open_lav(){
        if($("#sotto-menu-cat").attr("aperto") == "0"){
            //$("#sotto-menu-cat").fadeIn(1200);
            $('#sotto-menu-cat').animate({
                opacity: 1,
                left: '-=50',
                height: 'toggle'
            }, 1500, function() {
                $("#sotto-menu-cat").attr("aperto",1);
            });
        }else{
            $('#sotto-menu-cat').animate({
                opacity: 0.25,
                left: '+=50',
                height: 'toggle'
            }, 1500, function() {
                $("#sotto-menu-cat").attr("aperto",0);
            });
        }
    }
    
    
</script>
<%
    EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
    EntityManager em = emf.createEntityManager();
    List<Categoria> list = em.createNativeQuery("SELECT * from categoria ORDER BY ordine", Categoria.class).getResultList();
%>

<div id="left">
    <div class="grassetto"><a href="?">HOME</a></div>
    <div><a href="?page=storia">STORIA</a></div>
    <div><a href="?page=prodotti">PRODOTTI</a></div>
    <div><a href="javascript:open_lav();">LAVORAZIONI</a></div>
    
    <div id="sotto-menu-cat" style="<%=style_sotto_menu_cat%>" aperto="<%=aperto%>">
        <%for (Categoria c : list) {%>
        <div><a href="?page=lavorazioni&id=<%=c.getIdcategoria()%>"><%=c.getNome()%></a></div>
        <%}%>
    </div>
    <div><a href="?page=location">LOCATION</a></div>
    <div><a href="?page=contatti">CONTATTI</a></div>
</div>
<%em.close();%>